{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "073dccbf",
   "metadata": {},
   "source": [
    "# 上周内容"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "556af670",
   "metadata": {},
   "source": [
    " 1. API阅读文档考试\n",
    " 2. request\n",
    " 3. 百度通用图像识别"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bd0eb0c0",
   "metadata": {},
   "source": [
    "# 本周内容"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "281a98e4",
   "metadata": {},
   "source": [
    "## 1. 人脸识别概念和基础"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e1c146ca",
   "metadata": {},
   "source": [
    "## 2.人脸识别应用 "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "36c42099",
   "metadata": {},
   "source": [
    "## 3.人脸识别实践-face++\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "14031c7f",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (4124199490.py, line 21)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [1]\u001b[1;36m\u001b[0m\n\u001b[1;33m    'return_attributes':'gender,age,smiling,headpose,facequality,emotion,blur' # 检测人脸数据\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "import base64\n",
    "\n",
    "'''\n",
    "Face++ 人脸检测\n",
    "'''\n",
    "\n",
    "request_url = \"https://api-cn.faceplusplus.com/facepp/v3/detect\"\n",
    "# 二进制方式打开图片文件\n",
    "# 1.图片文件准备\n",
    "f = open('pika.jpg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "# 2. 酬载准备\n",
    "payload = {\n",
    "    'api_key':'209Q71ubeUhMjeUKMnbqI9kVWcTKW_XG',\n",
    "    'api_secret':'hn1Y-BH3Fv7Su9X6BuVFGs8cS_9tJatQ',\n",
    "    'image_base64':img\n",
    "    'return_attributes':'gender,age,smiling,headpose,facequality,emotion,blur' # 检测人脸数据\n",
    "}\n",
    "\n",
    "headers = {'content-type': 'application/x-www-form-urlencoded'}\n",
    "response = requests.post(request_url, data=payload, headers=headers)\n",
    "if response:\n",
    "    print (response.json())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "59271267",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
